#pragma once
#include <Windows.h>
#include "IWareDevice.h"
#include "WareEngineNameSpace.h"

BEGIN_WARE

class CSceneManager;
class IWndHandler;
class CD3D9Graphic;
class CAudioBass;

class CWareDevice : public IWareDevice
{
public:
	CWareDevice();
	~CWareDevice();

	virtual IGraphic*		CreateGraphic();
	virtual void			ReleaseGraphic( IGraphic* pGraphic );
	virtual VBOOL			Run();

	virtual ISceneManager*	GetSceneManager();
	virtual IAudio*			GetAudio();

	virtual void			GetMousePos( WareCommon::CVector2& vecOut );

	virtual void			SetWndHandler( IWndHandler* pHandler );

	virtual	void			OnResize( int32 nWidth, int32 nHeight );
	virtual void			OnWndSizing( int32 nSide, void* pRect );

	//////////////////////////////////////////////////////////////////////////
	VBOOL					Init( const SDeviceInfo& DeviceInfo );
	//////////////////////////////////////////////////////////////////////////

	static LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );

private:
	VBOOL					CreateMainWindow( int32 nWidth, int32 nHeight, DWORD dwStyle, VBOOL bMaximized, VBOOL bFullScreen, uint32 uIcon, VCHAR* szWindowTitle );
	void					RegisterClassEx( HINSTANCE hInstance );

	void					CalClientRect( float32 fRatioWidht2Height, RECT& Rect, VBOOL bWidthNoChange );

	LRESULT					OnMessageProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );

private:

	SDeviceInfo				m_DeviceInfo;
	HWND					m_hWnd;
	DWORD					m_dwStyle;

	int32					m_nWidthBorder;
	int32					m_nHeightBorder;

	CD3D9Graphic* 			m_pGraphic;
	IWndHandler*			m_pWndHandler;
	CSceneManager*			m_pSceneManager;
	CAudioBass*				m_pAudio;
};

END_WARE